//
//  LRGroupTableViewCell.m
//  本地生活圈
//
//  Created by admin on 15/8/14.
//  Copyright (c) 2015年 懒人. All rights reserved.
//

#import "LRGroupTableViewCell.h"
#import "LRGroupCollectionViewCell.h"


@interface LRGroupTableViewCell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowLayout;

@end

@implementation LRGroupTableViewCell

static NSString *identifierId = @"LRGroupCollectionViewCell";
- (void)awakeFromNib {
    // Initialization code
    [self.collectionView registerNib:[UINib nibWithNibName:identifierId bundle:nil] forCellWithReuseIdentifier:identifierId];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    self.collectionView.scrollEnabled = NO;
    self.flowLayout.itemSize = CGSizeMake(self.bounds.size.width / 5, self.bounds.size.height /2);
    self.flowLayout.minimumInteritemSpacing = 0;
    self.flowLayout.minimumLineSpacing = 0;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setGroup:(LRGroupModel *)group
{
    _group = group;
    [self.collectionView reloadData];
}
#pragma mark - UICollectionView 数据源&代理方法实现

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 8;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    LRGroupCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifierId forIndexPath:indexPath];
    cell.list = self.group.list[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [MBProgressHUD showSuccess:[NSString stringWithFormat:@"打开%zd页面",indexPath.row]];
}
@end
